package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.RoleBean;
import com.project.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private IRoleService service;
@RequestMapping("findByItem")
    public IPage<RoleBean> findByItem(Integer pageNo){
        return service.findByItem(pageNo);
    }
    @RequestMapping("findAll")
    public List<RoleBean> findAll(){
    return service.findAll();
    }
@RequestMapping("findById")
    public RoleBean findById(Integer id){
    return service.findById(id);
    }
@RequestMapping("add")
    public String add(String name,Integer[] powerId){
    RoleBean role = new RoleBean(name);
    service.add(role,powerId);
    return "ok";
    }
@RequestMapping("del")
    public String del(Integer roleId){
    service.del(roleId);
    return "ok";
}
@RequestMapping("update")
    public String update (Integer roleId,Integer[] powerId){
    service.update(roleId,powerId);
    return "ok";
}
}
